package com.android.view.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

/**
 * Created by TenFace
 * on 2017/11/1.
 */

public class CanAddListenerScrollView extends ScrollView {

    private ObserverScroll observerScroll;

    public CanAddListenerScrollView(Context context) {
        this(context, null);
    }

    public CanAddListenerScrollView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CanAddListenerScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @Override
    protected void onScrollChanged(int l, int t, int oldL, int oldT) {
        super.onScrollChanged(l, t, oldL, oldT);
        if (observerScroll != null) {
            observerScroll.onScrollChanged(this, l, t, oldL, oldT);
        }
    }

    public void addOnScrollListener(ObserverScroll observerScroll) {
        this.observerScroll = observerScroll;
    }


    public interface ObserverScroll {
        void onScrollChanged(ScrollView v, int l, int t, int oldL, int oldT);
    }

}
